package top.jaygao;

import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.codec.JsonJacksonCodec;
import org.redisson.config.Config;
import org.redisson.config.SingleServerConfig;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.io.IOException;

/**
 * @author JayGao
 * @date 2024-12-06 15:08
 * 配置文件方式
 **/
@Configuration
public class RedissonConfigClass {

    @Value(value = "${spring.redis.redisson.config}")
    private String redissonConfig;

    @Bean
    public RedissonClient getRedissonClient() throws IOException {
        Config config = Config.fromYAML(redissonConfig);

        return Redisson.create(config);
    }

}
